<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>教务管理主页</title>
    <link rel="stylesheet" href="../css/homePage.css"/>
    <script src="../js/public.js"></script>
</head>
<body>
<div id="div">
    <div id="page_left">
        <div id=page_left_fonts>
            <span id="homePage" onclick="sy()">首&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;页</span>
        </div>
    </div>
    <div id="Page_right">
        <div id="Page_right_module">
            <div id="Page_right_module1" onclick=refresh()>
                <div id="Page_right_module1_title">
                    <span id="wisdom">狗都不学Java</span>
                </div>
            </div>
            <div id="Page_right_module2">
                <div id="Page_right_module2_time"><span id="time">20:58:00</span></div>
                <div id="Page_right_module2_date"><span id="date">2023年4月8日</span></div>
            </div>
            <div id="Page_right_module3">
                <div id="Page_right_module3_headimg"></div>
                <div id="Page_right_module3_line"></div>
                <div id="Page_right_module3_info">
                    <span id="username"></span>
                    <span id="Page_right_module3_info_userinfo">个人信息
                            <div id="Page_right_userinfo">
                                <p>用户名:&nbsp;&nbsp;<span class="Page_right_userinfo_span" id="usernames"></span></p>
                                <!-- <span class = "Page_right_userinfo_line"></span> -->
                                <p>密&nbsp;&nbsp;&nbsp;码:&nbsp;&nbsp;<span id="password"></span></p>
                                <!-- <span class = "Page_right_userinfo_line"></span> -->
                                <p>性&nbsp;&nbsp;&nbsp;别:&nbsp;&nbsp;<span id="sex"></span></p>
                                <!-- <span class = "Page_right_userinfo_line"></span> -->
                                <p>年&nbsp;&nbsp;&nbsp;龄:&nbsp;&nbsp;<span id="age"></span></p>
                                <!-- <span class = "Page_right_userinfo_line"></span> -->
                                <p>生&nbsp;&nbsp;&nbsp;日:&nbsp;&nbsp;<span id="birthday"></span></p>
                                <!-- <span class = "Page_right_userinfo_line"></span> -->
                                <p>班级号:&nbsp;&nbsp;<span id="classid"></span></p>
                                <!-- <span class = "Page_right_userinfo_line"></span> -->
                                <p>职&nbsp;&nbsp;&nbsp;务:&nbsp;&nbsp;<span id="post"></span></p>
                                <!-- <span class = "Page_right_userinfo_line"></span> -->
                            </div>
                        </span>
                    <span id="userexit">退出登录</span>
                </div>
            </div>
        </div>
        <div id="Page_right_tabulation">
            <div id="Page_right_tabulation_title">
                <span id="Page_right_tabulation_title_head">123</span>
            </div>
            <div id="Page_right_tabulation_date">
                <span id="Page_right_tabulation_date_font">666</span>
            </div>
            <div id="Page_right_tabulation_info">
                <span id="Page_right_tabulation_title_info">345</span>
            </div>
        </div>
    </div>
</div>
</body>
</html>

<script src="../js/axios.js"></script>
<script>
    var date = new Date();

    window.onload = function () {
        // document.getElementById("div").style.height =   window.screen.availHeight - 120 + "px";
        document.getElementById("div").style.height =   window.screen.availHeight - 120 + "px";

        //精选语句(一级优先)
        var arr = ["承君此诺 必守一生", "Hello,World!", "青青子衿 悠悠我心", "知我者 谓我心忧", "不知我者 谓我何求", "丈夫志四海 万里犹比邻", "黄沙百战穿金甲 不破楼兰终不还", "但愿人长久 千里共婵娟", "千磨万击还坚劲 任尔东西南北风", "明日复明日 明日何其多", "Melody!!!"];
        var ran = Math.round(Math.random() * 10);
        document.getElementById("wisdom").innerHTML = arr[ran];

        //添加数据(一级优先)
        axios.post("http://localhost:8080/JWGLSystem/homePageServlet").then(function (resp) {
            users = resp.data;
            if (users.userName == undefined) {
                window.location.href = "../index.html";
            }
            document.getElementById("username").innerHTML += users.userName;
            document.getElementById("usernames").innerHTML += users.userName;
            document.getElementById("password").innerHTML += users.userPassword;
            document.getElementById("sex").innerHTML += users.userSex;
            document.getElementById("age").innerHTML += users.userAge;
            document.getElementById("classid").innerHTML += users.userClassId;
            document.getElementById("post").innerHTML += users.userPost;
            document.getElementById("birthday").innerHTML += users.userBirthday;

            //实现左侧菜单栏
            if (users.userPost == "管理") {
                document.getElementById("page_left_fonts").innerHTML +=
                    "            <span id='selectCourse' onclick='kccx()'>课程查询</span>\n" +
                    "            <span id='selectScore' onclick = 'cjcx()'>成绩查询</span>\n" +
                    "            <span id='addCourse' onclick = 'kcgl()'>课程管理</span>\n" +
                    "            <span id='adTeachers' onclick = 'gljs()'>管理教师</span>\n" +
                    "            <span id='adStudents' onclick='glxs()'>管理学生</span>\n" +
                    "            <span id='addAnn' onclick='ggfb()'>发布公告</span>\n" +
                    "            <span id='selectAnn' onclick='ggcx()'>公告查询</span>"
            } else if (users.userPost == "学生") {
                document.getElementById("page_left_fonts").innerHTML +=
                    "            <span id='selectCourse' onclick='kccx()'>课程查询</span>\n" +
                    "            <span id='selectScore'  onclick = 'cjcx()'>成绩查询</span>\n" +
                    "            <span id='selectAnn' onclick='ggcx()'>公告查询</span>"
            } else if (users.userPost == "老师") {
                document.getElementById("page_left_fonts").innerHTML +=
                    "            <span id='selectCourse' onclick='kccx()'>课程查询</span>\n" +
                    "            <span id='selectScore'  onclick = 'cjcx()'>成绩查询</span>\n" +
                    "            <span id='addCourse' onclick = 'kcgl()'>课程管理</span>\n" +
                    "            <span id='adStudents' onclick='glxs()'>管理学生</span>\n" +
                    "            <span id='addAnn' onclick='ggfb()'>发布公告</span>\n" +
                    "            <span id='selectAnn' onclick='ggcx()'>公告查询</span>"
            }
        });

        //实现首页公告信息
        axios.post("http://localhost:8080/JWGLSystem/homePageServletGG").then(function (resp) {
            // console.log(resp.data[resp.data.length-1]);
            document.getElementById("Page_right_tabulation_title").innerHTML = resp.data[resp.data.length-1].annTitle;
            document.getElementById("Page_right_tabulation_info").innerHTML = resp.data[resp.data.length-1].annContent;
            document.getElementById("Page_right_tabulation_date_font").innerHTML = "时间 " +resp. data[resp.data.length-1].annDate;
        });

        //退出登录功能
        document.getElementById("userexit").onclick = function () {
            axios.get("http://localhost:8080/JWGLSystem/exitServlet?cz=" + "exit").then(function (resp) {
                if (resp.data == "exit") {
                    window.location.href = "../index.html";
                }
            });
        }

        //鼠标移入个人信息
        document.getElementById("Page_right_module3_info_userinfo").onmouseover = function () {
            document.getElementById("Page_right_userinfo").style.display = "block";
        }

        //鼠标移除显示删除个人信息
        document.getElementById("Page_right_module3_info_userinfo").onmouseout = function () {
            document.getElementById("Page_right_userinfo").style.display = "none";
        }

        //显示当前日期
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var day = date.getDate();
        var week = date.getDay();
        if (week == "1") {
            week = "一";
        } else if (week == "2") {
            week = "二";
        } else if (week == "3") {
            week = "三";
        } else if (week == "4") {
            week = "四";
        } else if (week == "5") {
            week = "五";
        } else if (week == "6") {
            week = "六";
        } else if (week == "0") {
            week = "日";
        }
        month = (month > 9) ? month : ("0" + month);
        day = (day < 10) ? ("0" + day) : day;
        var today = year + "年" + month + "月" + day + "日/星期" + week;
        document.getElementById("date").innerHTML = today;
    }

    //显示当前时间
    var date = new Date();
    time = date.toLocaleTimeString();
    document.getElementById("time").innerHTML = time;
    setInterval(function () {
        date = new Date();
        time = date.toLocaleTimeString();
        document.getElementById("time").innerHTML = time;
    }, 1000);
</script>
</body>
</html>